import yaml
import os
import platform


def generator_config(config, out):
    with open(config, 'r') as f:
        cfg = yaml.load(f, Loader=yaml.FullLoader)
    shell = os.environ.get('SHELL')
    cfg['shell']['command'] = shell
    with open(out, 'w') as f:
        yaml.dump(cfg, f)
    return cfg


def default_path():
    plat = platform.platform()
    home = os.environ.get('HOME')
    if 'mac' in plat.lower():
        dst = os.path.join(home, "Library", "Application Support", "navi")
    os.makedirs(dst, exist_ok=True)
    return dst


if __name__ == "__main__":
    config = 'config.yaml'
    config_path = default_path()
    cfg = generator_config(config, os.path.join(config_path, 'config.yaml'))
